import requests
from lxml import etree
headers= {
    'Accept':'text/html,application/xhtml+xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
    'Accept-Encoding':'gzip,deflate',
    'Accept-Language':'zh-CN,zh;q=0.9',
    'User-Agent':'Mozilla/5.0 ( Windows NT 10.0;Win64;x64) AppleWebKit/537. 36 (KHTML,like Gecko) Chrome/74.0.3729.108 Safari/537.36'
}
def get_static():
    url='https://www.job5156. com/s/result/ktO/? keywordType =O&keyword= &locationList =&_csrf= 6Ke7YymD-m6dbgxq00h7UrQQmm2b8op98GmQ'
    response=requests.get(url,headers=headers)
    s=etree.HTML(response.text)
    infos=s.xpath('html/body/div[4]/div/div[2]/div[2]/ul/li')
    print(len(infos))
    for info in infos:
        comname=info.xpath('div/div[2]/a/@title')[0]
        r=info.xpath('div/viv[3]/div/text()')[0]
        r=r.split('|')
        if len(r) == 3:
            addr = r[2].strip()
            r1=r[0].strip()
            r2=r[1].strip()
            req=r1+','+r2
        else:
            addr=r[1].strip()
            req=r[0].strip()
        salary=info.xpath('div/div[2]/div/span/text()')[0]
        name=info.xpath('div/div[2]/div/p/a/text()')[0].strip()
        desc=info.xpath('div/div[4]/div/span/text()')[0]
        print(comname,addr,req,salary,name,desc)

if __name__ =='__main__':
    get_static()
